package com.hk.yajin.function.videos.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hk.developmentlib.utills.UiUtil;
import com.hk.yajin.R;
import com.hk.yajin.model.News;
import com.hk.yajin.model.Video;

import java.util.List;

/**
 * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
 */
public class VideoQuickAdapter extends BaseQuickAdapter<Video, BaseViewHolder> {

    private Context context;

    public VideoQuickAdapter(List<Video> datas, Context ct) {
        super(R.layout.list_item_video, datas);
        context = ct;
    }

    @Override
    protected void convert(BaseViewHolder helper, Video item) {
        //标题
        if (!TextUtils.isEmpty(item.getV_title())) {
            helper.setText(R.id.tv_title, item.getV_title());
        } else {
            helper.setText(R.id.tv_title, "");
        }
        //简介
        if (!TextUtils.isEmpty(item.getV_brief())) {
            helper.setText(R.id.tv_sum, item.getV_brief());
        } else {
            helper.setText(R.id.tv_sum, "");
        }
        //发布人
        if (!TextUtils.isEmpty(item.getTe_name())) {
            helper.setText(R.id.tv_name, item.getTe_name());
        } else {
            helper.setText(R.id.tv_name, "");
        }
        //观看
        helper.setText(R.id.tv_read_count, item.getV_watch_count() + "浏览");

        //图
        ImageView imageView = helper.getView(R.id.iv_logo);
        imageView.getLayoutParams().width = UiUtil.getScreenWidth() / 2;
        float rate = 15.0f / 22.0f;
        imageView.getLayoutParams().height = (int) (UiUtil.getScreenWidth() / 2 * rate);
        UiUtil.showNormalImage(imageView, item.getV_cover());
    }


}
